package concurrency.basicthreading.demo;
import java.util.concurrent.ThreadFactory;


public class Demo14HandlerThreadFactory implements ThreadFactory {

	@Override
	public Thread newThread(Runnable r) {
		System.out.println(this + "creating new Thread");
		Thread t = new Thread(r);
		System.out.println("created" + t);
		//ThreadFactory, 它将在每个新创建的Thread对象上附着一个Thread.UncaughtExceptionHandler。
		t.setUncaughtExceptionHandler(new Demo14UncaughtExceptionHandler());
		System.out.println("eh = " + t.getUncaughtExceptionHandler());
		return t;
	}

}
